package com.malou.client.util;

import java.util.ArrayList;
import java.util.List;

import com.extjs.gxt.ui.client.data.BeanModel;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.extjs.gxt.ui.client.widget.form.TextField;

public class Utilities {
	public static Integer itemsPerPage = 10;
	public static Double igv_value = 1.18;
	public static String tienda = null;
	
	public static boolean hasValue(TextField<String> field) {
	    return field.getValue() != null && field.getValue().length() > 0;
	}
	public static boolean hasValue(NumberField field) {
	    return field.getValue() != null && field.getValue().toString().length() > 0;
	}
	public static String toIds(List<BeanModel> list) {
		String ids="";
		for(BeanModel item : list){						
			ids += ","+item.get("id");
		 }
		 ids = ids.substring(1);
		return ids;
	}
	public static String toIdString(List<Integer> list) {
		String ids="";
		for(Integer id : list){						
			ids += ","+id;
		 }
		 ids = ids.substring(1);
		return ids;
	}
	public static List<Integer> toListIds(List<BeanModel> list) {
		List<Integer> retorno = new ArrayList<Integer>();		
		for(BeanModel item : list){			
			retorno.add(Integer.valueOf(item.get("id").toString()));
		 }
		return retorno;
	}
}
